package br.ufrj.dcc.dojo.jtrace;

import org.jtrace.Materials;
import org.jtrace.Scene;
import org.jtrace.Tracer;
import org.jtrace.cameras.Camera;
import org.jtrace.cameras.PinHoleCamera;
import org.jtrace.geometry.Plane;
import org.jtrace.geometry.Sphere;
import org.jtrace.lights.Light;
import org.jtrace.primitives.ColorRGB;
import org.jtrace.primitives.Point3D;
import org.jtrace.primitives.Vector3D;
import org.jtrace.shader.Shader;
import org.jtrace.shader.Shaders;

public class SingleSphere extends TracerComponents {
	
	public SingleSphere(int hres, int vres) {
		super(hres, vres);
	}
	
	@Override
	protected void createScene(Scene scene) {
		Point3D eye = new Point3D(-500, 0, 0);
		Point3D lookAt = new Point3D(0, 0, 0);
		Vector3D up = new Vector3D(0, 0, 1);
		
		Camera camera = new PinHoleCamera(eye, lookAt, up);
		camera.setZoomFactor(20d);
		scene.setCamera(camera);
		
		Sphere sphere = new Sphere(new Point3D(0, 0, 0), 10, Materials.metallic(ColorRGB.YELLOW));
		scene.add(sphere);
	
		Point3D pointPlane = new Point3D(0, 0, -50);
		Vector3D normalPlane = new Vector3D(0, 0, 1);
		Plane plane = new Plane(pointPlane, normalPlane, Materials.matte(ColorRGB.WHITE));
		scene.add(plane);
		
		Light light = new Light(new Point3D(-20,50,0));
		scene.add(light);
	}

	@Override
	protected void createTracer(Tracer tracer) {
		Shader ambient = Shaders.ambientShader();
		Shader diffuse = Shaders.diffuseShader();
		Shader specular = Shaders.specularShader(64);
		
		tracer.addShaders(ambient, diffuse, specular);
	}
	
}